package com.bestv.search.common.dataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class DataSourceKeyUtil {
    protected static Log log = LogFactory.getLog(DataSourceKeyUtil.class);

    /**
     * 转换字符串类型的SiteCode为 DataSourceKey类型
     *
     * @param siteCode ，驻地代码, 一般来说，驻地代码必须与当前驻地的DataSourceKey相等
     * @return DataSourceKey对象
     */
    public static DataSourceKey convert(String siteCode) {
        DataSourceKey[] types = DataSourceKey.values();
        for (DataSourceKey sc : types) {
            if (sc.toString().equalsIgnoreCase(siteCode)) {
                return sc;
            }
        }
        log.error("Invalid siteCode " + siteCode + " can't convert to DataSourceKey");
        return null;
    }
}
